<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" >
<title>Demo: canvas grid</title>
    <meta name="description" content="flyxiang">
    <link rel="shortcut icon" type="image/x-icon" href="http://flyxiang.org/www/img/favicon.ico">
    <link rel="apple-touch-icon" href="http://flyxiang.org/www/img/flyxiang_57.png">
    <link rel="apple-touch-icon" sizes="72x72" href="http://flyxiang.org/www/img/flyxiang_72.png">
    <link rel="apple-touch-icon" sizes="114x114" href="http://flyxiang.org/www/img/flyxiang_114.png">
    <link href="http://fonts.googleapis.com/css?family=Oswald" rel="stylesheet" type="text/css">
<style>
html,body {
	width: 100%;
}
	body {
	font-family: 'Open Sans',sans-serif;
	color:#333;
	background:#EDEDED;
	-webkit-text-size-adjust: none;
}
/*Custom text-selection colors*/
::-moz-selection {background: #F04530; color: #fff; text-shadow: none;}
::selection {background: #F04530; color: #fff; text-shadow: none;} 
a {
	color:#346AA8;
	text-decoration:none;
}

a:hover,
a:focus,
a:active {
	text-decoration:none;
}
h1 {
	text-align: center;
	margin-bottom: 20px;
	font-family: 'Oswald',sans-serif;
}
h1 a {
	font-size: 30px;
	font-weight: 400;
	text-decoration: none;
	color: #5FA4A0
}
h1 a:hover {
	color: #5FA4A0
}
.container {
	width: 501px;
	height: 371px;
	margin: 0 auto;
}
.ipt {
	width: 100%;
	border: #e2e2e2 1px solid;
	font-size: 1.2em;
	padding: 6px;
	border-radius: 2px;
}
footer {
	padding: 0 2em;
	font-size: 10px;
}
</style>
</head>
<body>
<section class="container">
	<h1><a href="http://www.flyxiang.org">Canvas Grid / Canvas 绘制网格</a></h1>
	<canvas id="c" width="501" height="371"></canvas>
</section>
<script>
function grid(id) {
  var cvs=document.getElementById(id);
  var cnt=cvs.getContext("2d");
  for(var x=0.5;x<=501;x+=10){
	cnt.moveTo(x,0);
	cnt.lineTo(x,370);
  }
  for(var y=0.5;y<=371;y+=10){
	cnt.moveTo(0,y);
	cnt.lineTo(500,y);
  }
  cnt.strokeStyle="#e0e0e0";
  cnt.stroke();
}
window.onload=function (){
  grid("c")
}
</script>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28937623-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
h2:first-child { ... }

div.text > div { ... } 
h2 + header { ... } 
</script>
</body>
</html>